package com.pt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pt.entity.ForumTopic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ForumTopicMapper extends BaseMapper<ForumTopic> {
    
    /**
     * 增加点赞数
     */
    @Update("UPDATE forum_topic SET like_count = like_count + 1 WHERE id = #{topicId}")
    void incrementLikeCount(Long topicId);

    /**
     * 减少点赞数
     */
    @Update("UPDATE forum_topic SET like_count = GREATEST(like_count - 1, 0) WHERE id = #{topicId}")
    void decrementLikeCount(Long topicId);
} 